<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport"
      content="width=device-width, initial-scale=0.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<meta name="keywords" content=""/>
<meta name="description" content="">
<meta name="author" content=""/>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<title>注册1</title>
<link rel="stylesheet" type="text/css" href="/assets/css/public.css">
<link rel="stylesheet" type="text/css" href="/assets/css/LQC.css">
<script src="/assets/js/jquery-1.9.0.min.js"></script>
<script src="/assets/js/hjk.js"></script>
<script type="text/javascript">
	function register(){
		var count = $("#count").val();
		var password = $("#password").val();
		if(vailPhone(count)){
			var url = "/user/checkPhoneIsExist";
			$.post(
				url,
				{phone:count},
				function(data){
					if(data == 1){
						if(password == ''){
							alert("密码不能为空");
						}else{
							var submitUrl = "/user/register/submit";
							$.post(
									submitUrl,
									{phone:count,pwd:password},
									function(data){
										alert("注册成功");
										window.location.href = "/user/login";
									}
							);
						}
					}else{
						alert("该手机号已被注册");
					}
				}
			);
		}
		
	}
	
	function vailPhone(phone){
        
        var flag = false;
        var message = "";
        var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;             
        if(phone == ''){
            message = "手机号码不能为空！";
        }else if(phone.length !=11){
            message = "请输入有效的手机号码！";
        }else if(!myreg.test(phone)){
            message = "请输入有效的手机号码！";
        }else{
                flag = true;
        }
        if(!flag){
       //提示错误效果
          alert(message);
          return flag;
        }else{
        	return flag;
        }
        
     }
	
</script>
</head>

<body class="body">
<header class="zc01_header">
 注册
 <div class="zc01_Qhc01">
  <a href="/user/login"><img src="/assets/images/nav_back@3x.png"></a>
 </div>
</header>
<article id="zc01_article">
 <div class="zc01_Qac01">
  <input id="count" name="count" class="zc01_Qnum" type="text" placeholder="输入手机号码" value=""></input>
  <input id="password" name="password" class="zc01_Qnum" id="zc01_Qkey" type="text" placeholder="输入密码" value=""></input>
 </div>

 <div id="tyzc_2">
 <div class="zc03_Qtijiao" onclick="register()">提交</div>
 </div>
  
 <div id="tyzc_1">
 <div class="zc01_Qtijiao" onclick="register()">提交</div>
 </div>
 

</article>
</body>
</html>
